#ifndef MATRIX_ENTRY_H
#define MATRIX_ENTRY_H

#include "DataTypes.h"
#include "MatrixException.h"

#include <iostream>

using namespace std;

template <typename T>
class MatrixEntry
{
    UINT _row; /* zero based row index */
    UINT _col; /* zero based column index */
    T _value;  /* value stored in the current entry */

    /**
     * @param row zero based row index. Refer MatrixEntry#MatrixEntry.
     */
    void setRow(UINT row);

    /**
     * @param col zero based column index. Refer MatrixEntry#MatrixEntry
     */
    void setCol(UINT col);

    /**
     * @param value element to be stored. Refer MatrixEntry#MatrixEntry
     */
    void setVal(T value);
    
public:
    /**
     * @param row zero based row index of the current entry.
     * @param col zero based column index of the current entry.
     * @param value element to be stored in (row, col)
     */
    MatrixEntry(UINT row, UINT col, T value);

    /**
     * Create a shallow copy to copyMe. if transpose if true, a deep copy of
     * copyMe.
     *
     * @param copyMe a non null Matrix Entry
     * @param transpose indicates whether shallow / deep copy should be taken.
     */
    MatrixEntry(MatrixEntry<T> *copyMe, BOOL transpose = FALSE);

    /**
     * resets row and column to 0. Value is set to default.
     */
    virtual ~MatrixEntry() throw();

    /**
     * @return a constant reference to the value stored.
     */
    const T& getVal();

    /**
     * @return zero based row index of the current cell.
     */
    UINT getRow();

    /**
     * @return zero based column index of the current cell.
     */
    UINT getCol();

    /**
     * prints the matrix entry.
     */
    void print();

    /**
     * Compares the matrix entry to compare_me.
     * Returns TRUE if the current matrix entry is greater than compare_me.
     * First compares the row. If rows are equal, columns are compared.
     *
     * @param compare_me Reference to the matrix entry to compare.
     */
    BOOL operator>(MatrixEntry<T> &compare_me);

    /**
     * Compares the matrix entry to compare_me.
     * Returns TRUE if the current matrix entry is lesser than compare_me.
     * First compares the row. If rows are equal, columns are compared.
     *
     * @param compare_me Reference to the matrix entry to compare.
     */
    BOOL operator<(MatrixEntry<T> &compare_me);


    /**
     * Compares the matrix entry to compare_me.
     * Returns TRUE if the current matrix entry is equal to compare_me.
     * First compares the row. If rows are equal, columns are compared.
     *
     * @param compare_me Reference to the matrix entry to compare.
     */
    BOOL operator==(MatrixEntry<T> &compare_me);
};

#include "MatrixEntry.cc"

#endif
